<?php
$pass = '';
if(!empty($this->params['pass'])){
	$pass = $this->params['pass'][0];
}
$html->addCrumb('Admin','/admin');
$html->addCrumb('User verwalten','/users/');
$html->addCrumb('User &auml;ndern','/admin/users/update/'.$pass,array('escape'=>false));

echo  $this->element('tasks',array('target'=>'/admin/users'));
?>
<div class="title">User ändern</div>

<?php echo $this->element('flashMessage');

echo $this->Form->create('User', array('action' => 'update','class'=> 'form'));
	
echo $this->Form->input('first_name', array('label' => 'Vorname: '));
echo $this->Form->input('family_name', array('label' => 'Nachname: '));
echo $this->Form->input('phone_number', array('label' => 'Telefon: '));
echo $this->Form->input('email', array('label' => 'Email: '));
echo '<br>';
echo $this->Form->input('username', array('label' => 'Username: '));
echo $this->Form->input('password', array('label' => 'Passwort: '));
echo $this->Form->input('state_id',array('label'=>'Status:'));
echo $this->Form->input('free_text', array('label' => 'Notiz: ','type'=>'textarea'));

echo '<div class="form_div_buttons">';
echo '<input type="submit" name="Ändern" value="Ändern">';
echo $this->Html->link('Abbrechen',array('action'=>'index'));
echo '</div>';

echo $this->Form->end();
													        
?>

<!-- update user roles ------------------------------------------------------------------------>
<br>
Rollen
<?php
$userId = $this->data['User']['id'];
echo $this->Form->create(null,array('action'=>'addRole',$userId )) 
?>
<table>
	<tr>
		<th><?php echo $this->Form->input('Role',array('label'=>'Rolle: ','type'=>'select')) ?></th>
		<th>
		<?php echo $this->Form->hidden('User.id',array('value'=>$userId)) ?>
		<?php echo $this->Form->hidden('State.id',array('value'=>1)) ?>
		<?php echo $this->Form->submit('zuordnen') ?>
		</th>
	</tr>
	<tr>
		<th>Rolle</th>
		<th>Aktion</th>
	</tr>
	
	<?php
	$out = '';
	foreach($this->data['Role'] as $key => $role){
		$roleId  = $role['UserHasRole']['id'];
		$out .= "<tr>";
		$out .= '<td>'.$role['role_name'].'</td>';
		$out .= '<td>';
		$out .= $this->Html->link('Löschen',array('action'=>'deleteRole',$userId, $roleId));
		$out .= '</td>';
		$out .= "</tr>";
	}
	echo $out;
	?>
</table>
<?php echo $this->Form->end() ?>











